package com.btpn.custody.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import com.btpn.custody.common.Constant;

@Entity
@org.hibernate.annotations.Entity(dynamicInsert=true, dynamicUpdate=true)
@Table(name = "M_ADDRESS")
@NamedQueries({
				@NamedQuery(name  = "Address.getByMD_AddressType",
							query = "FROM Address a WHERE a.masterData.sid= :mdSid AND a.ADDRESS_TYPE = :addressType"),
							
				@NamedQuery(name  = "Address.findByMD",
							query = "FROM Address a WHERE a.masterData.sid = :mdSid")
})
public class Address implements Serializable {

	/*=============================================== C O N S T A N T =========================================*/
	private static final long serialVersionUID = 8084419856276917479L;

	public static final String NQ__GET_BY_MD_AND_ADDRESS_TYPE 	= "Address.getByMD_AddressType";
	
	public static final String NQ__FIND_BY_MD 	= "Address.findByMD";
	
	public static final String PRIME_ADDRESS 	= "3";
	public static final String HOME_ADDRESS 	= "1";
	public static final String OFFICE_ADDRESS 	= "2";
	public static final String EMAILING_ADDRESS = "8";
	/*=============================================== M E M B E R =============================================*/
// BASIC
	@Id 
	@GeneratedValue
	@Column(name = "__ID")
	private Long id;
	
	@Column(name = "__CREATED_DATE")
	private Date createdDate = new Date();

	@Column(name = "__CREATED_BY")
	private String createdBy = Constant.USER_SYSTEM;

	@Column(name = "__LAST_UPDATED_DATE")
	private Date lastUpdatedDate = new Date();

	@Column(name = "__LAST_UPDATED_BY")
	private String lastUpdatedBy;
	
// ADDRESS
	@Column(name = "ADDRESS1", columnDefinition="VARCHAR(88)")
	private String ADDRESS1;
	
	@Column(name = "ADDRESS2", columnDefinition="VARCHAR(88)")
	private String ADDRESS2;
	
	@Column(name = "ADDRESS3", columnDefinition="VARCHAR(88)")
	private String ADDRESS3;
	
	@Column(name = "ADDRESS4", columnDefinition="VARCHAR(88)")
	private String ADDRESS4;
	
	@Column(name = "ADDRESS5", columnDefinition="VARCHAR(88)")
	private String ADDRESS5;
	
	@Column(name = "POST_CODE", columnDefinition="VARCHAR(10)")
	private String POST_CODE;

	// 1:home, 2:office, 8:emailing, 3:KTP(prime, i define it)
	@Column(name = "ADDRESS_TYPE", columnDefinition="VARCHAR(1)")
	private String ADDRESS_TYPE;
	
	@ManyToOne
	@JoinColumn(name="MD_ID")
	private MasterData masterData;
	
	/*=============================================== G E T T E R   &   S E T T E R ===========================*/
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Date getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public String getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(String createdBy) {
		this.createdBy = createdBy;
	}

	public Date getLastUpdatedDate() {
		return lastUpdatedDate;
	}

	public void setLastUpdatedDate(Date lastUpdatedDate) {
		this.lastUpdatedDate = lastUpdatedDate;
	}

	public String getLastUpdatedBy() {
		return lastUpdatedBy;
	}

	public void setLastUpdatedBy(String lastUpdatedBy) {
		this.lastUpdatedBy = lastUpdatedBy;
	}

	public String getADDRESS1() {
		return ADDRESS1;
	}

	public void setADDRESS1(String aDDRESS1) {
		ADDRESS1 = aDDRESS1;
	}

	public String getADDRESS2() {
		return ADDRESS2;
	}

	public void setADDRESS2(String aDDRESS2) {
		ADDRESS2 = aDDRESS2;
	}

	public String getADDRESS3() {
		return ADDRESS3;
	}

	public void setADDRESS3(String aDDRESS3) {
		ADDRESS3 = aDDRESS3;
	}

	public String getADDRESS4() {
		return ADDRESS4;
	}

	public void setADDRESS4(String aDDRESS4) {
		ADDRESS4 = aDDRESS4;
	}

	public String getADDRESS5() {
		return ADDRESS5;
	}

	public void setADDRESS5(String aDDRESS5) {
		ADDRESS5 = aDDRESS5;
	}

	public String getPOST_CODE() {
		return POST_CODE;
	}

	public void setPOST_CODE(String pOST_CODE) {
		POST_CODE = pOST_CODE;
	}

	public String getADDRESS_TYPE() {
		return ADDRESS_TYPE;
	}

	public void setADDRESS_TYPE(String aDDRESS_TYPE) {
		ADDRESS_TYPE = aDDRESS_TYPE;
	}

	public MasterData getMasterData() {
		return masterData;
	}

	public void setMasterData(MasterData masterData) {
		this.masterData = masterData;
	}
}
